#if defined(FEATURE_DATA_TYPE_INT8)
    %define PICO_FEATURE_DATA_TYPE_INT8
    %define PICO_BPE 8
#else
    #error " PICO_FEATURE_DATA_TYPE_INT8 must be set"
#endif

#if defined(WEIGHT_DATA_TYPE_INT8)
    %define PICO_WEIGHT_DATA_TYPE_INT8
#else
    #error " PICO_WEIGHT_DATA_TYPE_INT8 must be set"
#endif


#if defined(WEIGHT_COMPRESSION_ENABLE)
    %define PICO_WEIGHT_COMPRESSION_ENABLE
#elif defined(WEIGHT_COMPRESSION_DISABLE)
#else
    #error "one of PICO_WEIGHT_COMPRESSION_{EN,DIS}ABLE must be set"
#endif

#if defined(WINOGRAD_ENABLE)
    %define PICO_WINOGRAD_ENABLE
#elif defined(WINOGRAD_DISABLE)
#else
    #error "one of PICO_WINOGRAD_{EN,DIS}ABLE must be set"
#endif

#if defined(BATCH_ENABLE)
    %define PICO_BATCH_ENABLE 
#elif defined(BATCH_DISABLE)
#else
    #error "one of PICO_BATCH_{EN,DIS}ABLE must be set"
#endif

#if defined(SECONDARY_MEMIF_ENABLE)
    %define PICO_SECONDARY_MEMIF_ENABLE
#elif defined(SECONDARY_MEMIF_DISABLE)
#else
    #error "one of PICO_SECONDARY_MEMIF_{EN,DIS}ABLE must be set"
#endif

#if defined(SDP_LUT_ENABLE)
    %define PICO_SDP_LUT_ENABLE 
#elif defined(SDP_LUT_DISABLE)
#else
    #error "one of PICO_SDP_LUT_{EN,DIS}ABLE must be set"
#endif

#if defined(SDP_BS_ENABLE)
    %define PICO_SDP_BS_ENABLE
#elif defined(SDP_BS_DISABLE)
#else
    #error "one of PICO_SDP_BS_{EN,DIS}ABLE must be set"
#endif

#if defined(SDP_BN_ENABLE)
    %define PICO_SDP_BN_ENABLE
#elif defined(SDP_BN_DISABLE)
#else
    #error "one of PICO_SDP_BN_{EN,DIS}ABLE must be set"
#endif

#if defined(SDP_EW_ENABLE)
    %define PICO_SDP_EW_ENABLE
#elif defined(SDP_EW_DISABLE)
#else
    #error "one of PICO_SDP_EW_{EN,DIS}ABLE must be set"
#endif

#if defined(BDMA_ENABLE)
    %define PICO_BDMA_ENABLE
#elif defined(BDMA_DISABLE)
#else
    #error "one of PICO_BDMA_{EN,DIS}ABLE must be set"
#endif

#if defined(RUBIK_ENABLE)
    %define PICO_RUBIK_ENABLE 
#elif defined(RUBIK_DISABLE)
#else
    #error "one of PICO_RUBIK_{EN,DIS}ABLE must be set"
#endif

#if defined(RUBIK_CONTRACT_ENABLE)
    %define PICO_RUBIK_CONTRACT_ENABLE
#elif defined(RUBIK_CONTRACT_DISABLE)
#else
    #error "one of PICO_RUBIK_CONTRACT_{EN,DIS}ABLE must be set"
#endif

#if defined(RUBIK_RESHAPE_ENABLE)
    %define PICO_RUBIK_RESHAPE_ENABLE
#elif defined(RUBIK_RESHAPE_DISABLE)
#else
    #error "one of PICO_RUBIK_RESHAPE_{EN,DIS}ABLE must be set"
#endif

#if defined(PDP_ENABLE)
    %define PICO_PDP_ENABLE
#elif defined(PDP_DISABLE)
#else
    #error "one of PICO_PDP_{EN,DIS}ABLE must be set"
#endif

#if defined(CDP_ENABLE)
    %define PICO_CDP_ENABLE
#elif defined(CDP_DISABLE)
#else
    #error "one of PICO_CDP_{EN,DIS}ABLE must be set"
#endif

#if defined(RETIMING_ENABLE)
    %define PICO_RETIMING_ENABLE
#elif defined(RETIMING_DISABLE)
#else
    #error "one of PICO_RETIMING_{EN,DIS}ABLE must be set"
#endif

#if defined(MAC_ATOMIC_C_SIZE_64)
    %define PICO_MAC_ATOMIC_C_SIZE 64 
#elif defined(MAC_ATOMIC_C_SIZE_32)
    %define PICO_MAC_ATOMIC_C_SIZE 32 
#elif defined(MAC_ATOMIC_C_SIZE_8)
    %define PICO_MAC_ATOMIC_C_SIZE 8 
#else
    #error "one of PICO_MAC_ATOMIC_C_SIZE_{64,32,8} must be set"
#endif

#if defined(MAC_ATOMIC_K_SIZE_32)
    %define PICO_MAC_ATOMIC_K_SIZE 32
#elif defined(MAC_ATOMIC_K_SIZE_16)
    %define PICO_MAC_ATOMIC_K_SIZE 16
#elif defined(MAC_ATOMIC_K_SIZE_8)
    %define PICO_MAC_ATOMIC_K_SIZE 8
#else
    #error "one of PICO_MAC_ATOMIC_K_SIZE_{32,16,8} must be set"
#endif

#if defined(MEMORY_ATOMIC_SIZE_32)
    %define PICO_MEMORY_ATOMIC_SIZE 32
#elif defined(MEMORY_ATOMIC_SIZE_16)
    %define PICO_MEMORY_ATOMIC_SIZE 16
#elif defined(MEMORY_ATOMIC_SIZE_8)
    %define PICO_MEMORY_ATOMIC_SIZE 8
#else
    #error "one of PICO_MEMORY_ATOMIC_SIZE_{32,16,8} must be set"
#endif

#if defined(MAX_BATCH_SIZE_32)
    %define PICO_MAX_BATCH_SIZE 32
#elif defined(MAX_BATCH_SIZE_x) 
#else
    #error "one of PICO_MAX_BATCH_SIZE_{32,x} must be set"
#endif

#if defined(CBUF_BANK_NUMBER_16)
    %define PICO_CBUF_BANK_NUMBER 16
#elif defined(CBUF_BANK_NUMBER_32)
    %define PICO_CBUF_BANK_NUMBER 32
#else
    #error "one of PICO_CBUF_BANK_NUMBER_{16,32} must be set"
#endif

#if defined(CBUF_BANK_WIDTH_64)
    %define PICO_CBUF_BANK_WIDTH 64
#elif defined(CBUF_BANK_WIDTH_32)
    %define PICO_CBUF_BANK_WIDTH 32
#elif defined(CBUF_BANK_WIDTH_8)
    %define PICO_CBUF_BANK_WIDTH 8
#else
    #error "one of PICO_CBUF_BANK_WIDTH_{64,32,8} must be set"
#endif

#if defined(CBUF_BANK_DEPTH_512)
    %define PICO_CBUF_BANK_DEPTH 512
#elif defined(CBUF_BANK_DEPTH_128)
    %define PICO_CBUF_BANK_DEPTH 128
#else
    #error "only PICO_CBUF_BANK_DEPTH_{512,128} can be set"
#endif

#if defined(SDP_BS_ENABLE)
 #if defined(SDP_BS_THROUGHPUT_16)
     %define PICO_SDP_BS_THROUGHPUT 16
 #elif defined(SDP_BS_THROUGHPUT_8)
     %define PICO_SDP_BS_THROUGHPUT 8
 #elif defined(SDP_BS_THROUGHPUT_4)
     %define PICO_SDP_BS_THROUGHPUT 4
 #elif defined(SDP_BS_THROUGHPUT_2)
     %define PICO_SDP_BS_THROUGHPUT 2
 #elif defined(SDP_BS_THROUGHPUT_1)
     %define PICO_SDP_BS_THROUGHPUT 1

 #else
     #error "one of PICO_SDP_BS_THROUGHPUT_{16,8,4,2,1} must be set"
 #endif
#else
     %define PICO_SDP_BS_THROUGHPUT 0 
#endif 

#if defined(SDP_BN_ENABLE)
 #if defined(SDP_BN_THROUGHPUT_16)
     %define PICO_SDP_BN_THROUGHPUT 16 
 #elif defined(SDP_BN_THROUGHPUT_8)
     %define PICO_SDP_BN_THROUGHPUT 8
 #elif defined(SDP_BN_THROUGHPUT_4)
     %define PICO_SDP_BN_THROUGHPUT 4
 #elif defined(SDP_BN_THROUGHPUT_2)
     %define PICO_SDP_BN_THROUGHPUT 2
 #elif defined(SDP_BN_THROUGHPUT_1)
     %define PICO_SDP_BN_THROUGHPUT 1

 #else
     #error "one of PICO_SDP_BN_THROUGHPUT_{16,8,4,2,1} must be set"
 #endif
#else
     %define PICO_SDP_BN_THROUGHPUT 0 
#endif

#if defined(SDP_EW_ENABLE)
 #if defined(SDP_EW_THROUGHPUT_4)
     %define PICO_SDP_EW_THROUGHPUT 4
 #elif defined(SDP_EW_THROUGHPUT_2)
     %define PICO_SDP_EW_THROUGHPUT 2
 #elif defined(SDP_EW_THROUGHPUT_1)
     %define PICO_SDP_EW_THROUGHPUT 1
 #elif defined(SDP_EW_THROUGHPUT_x)
     %define PICO_SDP_EW_THROUGHPUT 1
 #else
     #error "one of PICO_SDP_EW_THROUGHPUT_{4,2,1,x} must be set"
 #endif
     %define PICO_SDP_EW_THROUGHPUT_LOG2  log2(PICO_SDP_EW_THROUGHPUT)
#else
     %define PICO_SDP_EW_THROUGHPUT 0
     %define PICO_SDP_EW_THROUGHPUT_LOG2  0
#endif

%define PICO_SDP_MAX_THROUGHPUT max(PICO_SDP_EW_THROUGHPUT, PICO_SDP_BN_THROUGHPUT,PICO_SDP_BS_THROUGHPUT)
%define PICO_SDP2PDP_WIDTH  (PICO_SDP_MAX_THROUGHPUT * PICO_BPE)

#if defined(PDP_THROUGHPUT_8)
    %define PICO_PDP_THROUGHPUT 8
#elif defined(PDP_THROUGHPUT_4)
    %define PICO_PDP_THROUGHPUT 4
#elif defined(PDP_THROUGHPUT_2)
    %define PICO_PDP_THROUGHPUT 2
#elif defined(PDP_THROUGHPUT_1)
    %define PICO_PDP_THROUGHPUT 1

#else
    #error "one of PICO_PDP_THROUGHPUT_{8,4,2,1} must be set"
#endif

#if defined(CDP_THROUGHPUT_8)
    %define PICO_CDP_THROUGHPUT 8
#elif defined(CDP_THROUGHPUT_4)
    %define PICO_CDP_THROUGHPUT 4
#elif defined(CDP_THROUGHPUT_2)
    %define PICO_CDP_THROUGHPUT 2
#elif defined(CDP_THROUGHPUT_1)
    %define PICO_CDP_THROUGHPUT 1
#else
    #error "one of PICO_CDP_THROUGHPUT_{8,4,2,1} must be set"
#endif

#if defined(PRIMARY_MEMIF_LATENCY_1024)
    %define PICO_PRIMARY_MEMIF_LATENCY 1024
#elif defined(PRIMARY_MEMIF_LATENCY_256)
    %define PICO_PRIMARY_MEMIF_LATENCY 256
#elif defined(PRIMARY_MEMIF_LATENCY_64)
    %define PICO_PRIMARY_MEMIF_LATENCY 64
#else
    #error "one of PICO_PRIMARY_MEMIF_LATENCY_{1024,256,64} must be set"
#endif

#if defined(SECONDARY_MEMIF_LATENCY_1024)
    %define PICO_SECONDARY_MEMIF_LATENCY 1024
#elif defined(SECONDARY_MEMIF_LATENCY_256)
    %define SECONDARY_MEMIF_LATENCY   256
#elif defined(SECONDARY_MEMIF_LATENCY_64)
    %define SECONDARY_MEMIF_LATENCY   64
#elif defined(SECONDARY_MEMIF_LATENCY_x)
#else
    #error "one of PICO_SECONDARY_MEMIF_LATENCY_{1024,256,64,x} must be set"
#endif

#if defined(PRIMARY_MEMIF_MAX_BURST_LENGTH_1)
    %define PICO_PRIMARY_MEMIF_MAX_BURST_LENGTH 1
#elif defined(PRIMARY_MEMIF_MAX_BURST_LENGTH_4)
    %define PICO_PRIMARY_MEMIF_MAX_BURST_LENGTH 4
#else
    #error "one of PICO_PRIMARY_MEMIF_MAX_BURST_LENGTH_{1,4} must be set"
#endif

#if defined(PRIMARY_MEMIF_WIDTH_256)
    %define PICO_PRIMARY_MEMIF_WIDTH 256
#elif defined(PRIMARY_MEMIF_WIDTH_128)
    %define PICO_PRIMARY_MEMIF_WIDTH 128
#elif defined(PRIMARY_MEMIF_WIDTH_64)
    %define PICO_PRIMARY_MEMIF_WIDTH 64
#else
    #error "one of PICO_PRIMARY_MEMIF_WIDTH_{256,128,64} must be set"
#endif

#if defined(SECONDARY_MEMIF_MAX_BURST_LENGTH_1)
    %define PICO_SECONDARY_MEMIF_MAX_BURST_LENGTH 1
#elif defined(SECONDARY_MEMIF_MAX_BURST_LENGTH_4)
    %define PICO_SECONDARY_MEMIF_MAX_BURST_LENGTH 4
#elif defined(SECONDARY_MEMIF_MAX_BURST_LENGTH_x)
#else
    #error "one of PICO_SECONDARY_MEMIF_MAX_BURST_LENGTH_{1,4,x} must be set"
#endif

#if defined(SECONDARY_MEMIF_WIDTH_256)
    %define PICO_SECONDARY_MEMIF_WIDTH 256
#elif defined(SECONDARY_MEMIF_WIDTH_128)
    %define PICO_SECONDARY_MEMIF_WIDTH 128
#elif defined(SECONDARY_MEMIF_WIDTH_64)
    %define PICO_SECONDARY_MEMIF_WIDTH 64
#elif defined(SECONDARY_MEMIF_WIDTH_x)
#else
    #error "one of PICO_SECONDARY_MEMIF_WIDTH_{256,128,64,x} must be set"
#endif

#if defined(MEM_ADDRESS_WIDTH_64)
    %define PICO_MEM_ADDRESS_WIDTH 64
#elif defined(MEM_ADDRESS_WIDTH_32)
    %define PICO_MEM_ADDRESS_WIDTH 32
#else
    #error "one of PICO_PRIMARY_MEMIF_WIDTH_{64,32} must be set"
#endif

#if defined(SECONDARY_MEMIF_ENABLE)
    %define PICO_MEMIF_WIDTH max(PICO_PRIMARY_MEMIF_WIDTH, PICO_SECONDARY_MEMIF_WIDTH, PICO_MEMORY_ATOMIC_SIZE*PICO_BPE)
#elif defined(SECONDARY_MEMIF_DISABLE)
    %define PICO_MEMIF_WIDTH max(PICO_PRIMARY_MEMIF_WIDTH, PICO_MEMORY_ATOMIC_SIZE*PICO_BPE)
#else
    #error "one of PICO_SECONDARY_MEMIF_{EN,DIS}ABLE must be set"
#endif

%define PICO_DMA_RD_SIZE   15
%define PICO_DMA_WR_SIZE   13
%define PICO_DMA_MASK_BIT int( PICO_MEMIF_WIDTH / PICO_BPE / PICO_MEMORY_ATOMIC_SIZE )
%define PICO_DMA_RD_RSP   int( PICO_MEMIF_WIDTH + PICO_DMA_MASK_BIT )
%define PICO_DMA_WR_REQ   int( PICO_MEMIF_WIDTH + PICO_DMA_MASK_BIT + 1 )
%define PICO_DMA_WR_CMD   int( PICO_MEM_ADDRESS_WIDTH + PICO_DMA_WR_SIZE +1)
%define PICO_DMA_RD_REQ   int( PICO_MEM_ADDRESS_WIDTH + PICO_DMA_RD_SIZE )

%define PICO_MEMORY_ATOMIC_LOG2  log2(PICO_MEMORY_ATOMIC_SIZE)
%define PICO_PRIMARY_MEMIF_WIDTH_LOG2 log2(PICO_PRIMARY_MEMIF_WIDTH/8)
#if defined(SECONDARY_MEMIF_WIDTH_x)
#else
    %define PICO_SECONDARY_MEMIF_WIDTH_LOG2 log2(PICO_SECONDARY_MEMIF_WIDTH/8)
#endif

%define PICO_MEMORY_ATOMIC_WIDTH   PICO_MEMORY_ATOMIC_SIZE*PICO_BPE
%define PICO_MCIF_BURST_SIZE       PICO_PRIMARY_MEMIF_MAX_BURST_LENGTH*PICO_DMA_MASK_BIT
%define PICO_MCIF_BURST_SIZE_LOG2  log2(PICO_MCIF_BURST_SIZE)


#if defined(NUM_DMA_READ_CLIENTS_10)
    %define PICO_NUM_DMA_READ_CLIENTS 10
#elif defined(NUM_DMA_READ_CLIENTS_8)
    %define PICO_NUM_DMA_READ_CLIENTS 8
#elif defined(NUM_DMA_READ_CLIENTS_7)
    %define PICO_NUM_DMA_READ_CLIENTS 7
#endif

#if defined(NUM_DMA_WRITE_CLIENTS_5)
    %define PICO_NUM_DMA_WRITE_CLIENTS 5
#elif defined(NUM_DMA_WRITE_CLIENTS_3)
    %define PICO_NUM_DMA_WRITE_CLIENTS 3
#endif



#if defined(DESIGNWARE_NOEXIST)
    %define DESIGNWARE_NOEXIST
#endif


%define PDP_SINGLE_LBUF_WIDTH int(16*PICO_MEMORY_ATOMIC_SIZE/PICO_PDP_THROUGHPUT)
%define PDP_SINGLE_LBUF_DEPTH int(PICO_PDP_THROUGHPUT*(PICO_BPE+6))

%define PICO_VMOD_PRIMARY_BANDWIDTH  int(PICO_PRIMARY_MEMIF_WIDTH/PICO_BPE/4)
%define PICO_VMOD_SDP_MRDMA_OUTPUT_THROUGHPUT PICO_SDP_MAX_THROUGHPUT
%define PICO_VMOD_SDP_BRDMA_OUTPUT_THROUGHPUT 4*PICO_SDP_BS_THROUGHPUT
%define PICO_VMOD_SDP_NRDMA_OUTPUT_THROUGHPUT 4*PICO_SDP_BN_THROUGHPUT
%define PICO_VMOD_SDP_ERDMA_OUTPUT_THROUGHPUT 4*PICO_SDP_EW_THROUGHPUT
%define PICO_VMOD_CDP_RDMA_OUTPUT_THROUGHPUT_USE min(PICO_CDP_THROUGHPUT, PICO_VMOD_PRIMARY_BANDWIDTH)
%define PICO_VMOD_PDP_RDMA_OUTPUT_THROUGHPUT_USE min(PICO_PDP_THROUGHPUT, PICO_VMOD_PRIMARY_BANDWIDTH)
%define PICO_VMOD_SDP_MRDMA_OUTPUT_THROUGHPUT_USE min(PICO_VMOD_SDP_MRDMA_OUTPUT_THROUGHPUT, PICO_VMOD_PRIMARY_BANDWIDTH)
%define PICO_VMOD_SDP_BRDMA_OUTPUT_THROUGHPUT_USE min(PICO_VMOD_SDP_BRDMA_OUTPUT_THROUGHPUT, PICO_VMOD_PRIMARY_BANDWIDTH)
%define PICO_VMOD_SDP_NRDMA_OUTPUT_THROUGHPUT_USE min(PICO_VMOD_SDP_NRDMA_OUTPUT_THROUGHPUT, PICO_VMOD_PRIMARY_BANDWIDTH)
%define PICO_VMOD_SDP_ERDMA_OUTPUT_THROUGHPUT_USE min(PICO_VMOD_SDP_ERDMA_OUTPUT_THROUGHPUT, PICO_VMOD_PRIMARY_BANDWIDTH)
%define PICO_VMOD_CDP_RDMA_LATENCY_FIFO_DEPTH  max(4,ceil(PICO_PRIMARY_MEMIF_LATENCY*PICO_VMOD_CDP_RDMA_OUTPUT_THROUGHPUT_USE/(PICO_MEMIF_WIDTH/PICO_BPE)))
%define PICO_VMOD_PDP_RDMA_LATENCY_FIFO_DEPTH  max(4,ceil(PICO_PRIMARY_MEMIF_LATENCY*PICO_VMOD_PDP_RDMA_OUTPUT_THROUGHPUT_USE/(PICO_MEMIF_WIDTH/PICO_BPE)))
%define PICO_VMOD_SDP_MRDMA_LATENCY_FIFO_DEPTH max(4,ceil(PICO_PRIMARY_MEMIF_LATENCY*PICO_VMOD_SDP_MRDMA_OUTPUT_THROUGHPUT_USE/(PICO_MEMIF_WIDTH/PICO_BPE)))
%define PICO_VMOD_SDP_BRDMA_LATENCY_FIFO_DEPTH max(4,ceil(PICO_PRIMARY_MEMIF_LATENCY*PICO_VMOD_SDP_BRDMA_OUTPUT_THROUGHPUT_USE/(PICO_MEMIF_WIDTH/PICO_BPE)))
%define PICO_VMOD_SDP_NRDMA_LATENCY_FIFO_DEPTH max(4,ceil(PICO_PRIMARY_MEMIF_LATENCY*PICO_VMOD_SDP_NRDMA_OUTPUT_THROUGHPUT_USE/(PICO_MEMIF_WIDTH/PICO_BPE)))
%define PICO_VMOD_SDP_ERDMA_LATENCY_FIFO_DEPTH max(4,ceil(PICO_PRIMARY_MEMIF_LATENCY*PICO_VMOD_SDP_ERDMA_OUTPUT_THROUGHPUT_USE/(PICO_MEMIF_WIDTH/PICO_BPE)))
%define PICO_VMOD_DMA_LAT_FIFO_DEPTH_MAX 512


%define PICO_MAC_ATOMIC_C_SIZE_LOG2    log2(PICO_MAC_ATOMIC_C_SIZE)
%define PICO_MAC_ATOMIC_K_SIZE_LOG2    log2(PICO_MAC_ATOMIC_K_SIZE)
%define PICO_MAC_ATOMIC_K_SIZE_DIV2    int(PICO_MAC_ATOMIC_K_SIZE/2)
%define PICO_CBUF_BANK_NUMBER_LOG2     log2(PICO_CBUF_BANK_NUMBER)
%define PICO_CBUF_BANK_WIDTH_LOG2      log2(PICO_CBUF_BANK_WIDTH)
%define PICO_CBUF_BANK_DEPTH_LOG2      log2(PICO_CBUF_BANK_DEPTH)
%define PICO_CBUF_DEPTH_LOG2           log2(PICO_CBUF_BANK_NUMBER)+log2(PICO_CBUF_BANK_DEPTH)
%define PICO_CBUF_ENTRY_WIDTH          PICO_MAC_ATOMIC_C_SIZE*PICO_BPE
%define PICO_CBUF_WIDTH_LOG2           log2(PICO_CBUF_ENTRY_WIDTH)
%define PICO_CBUF_WIDTH_MUL2_LOG2      log2(PICO_CBUF_ENTRY_WIDTH)+1
%define PICO_BPE_LOG2                  log2(PICO_BPE)
%define PICO_MAC_RESULT_WIDTH          PICO_BPE*2+PICO_MAC_ATOMIC_C_SIZE_LOG2
%define PICO_CC_ATOMC_DIV_ATOMK        int(PICO_MAC_ATOMIC_C_SIZE/PICO_MAC_ATOMIC_K_SIZE)
%define PICO_CACC_SDP_WIDTH            ((32*PICO_SDP_MAX_THROUGHPUT) +2)
%define PICO_CACC_SDP_SINGLE_THROUGHPUT 32

%define PICO_CDMA_GRAIN_MAX_BIT       log2(PICO_CBUF_BANK_DEPTH*PICO_CBUF_BANK_WIDTH*(PICO_CBUF_BANK_NUMBER-1)/(PICO_MEMORY_ATOMIC_SIZE)) 
